package com.cvtt.xmpp.cvttmessage;

import java.util.Vector;

import com.cvtt.xmpp.XMPPConfig;

public class CVTTMessage {
	private String cvttMsgXML = "<cvttmessage version=\"1.0\">\r\n" + "<type>%s</type>\r\n" + "<from  uid=\"%s\" />\r\n" + "%s" + "<content><![CDATA[%s]]></content>\r\n"
			+ "<attachment><![CDATA[%s]]></attachment>\r\n" + "<remark><![CDATA[%s]]></remark>\r\n" + "<status>%s</status>\r\n" + "<audiotime><![CDATA[%s]]></audiotime>\r\n" + "</cvttmessage>";
	private String toNodeXml = "<to uid=\"%s\" />\r\n";
	private String type = "";
	private String fromUID = "";
	private Vector<CVTTUserNode> toList;
	private String content = "";
	private String attachment = "";
	private String remark = "";
	private String status = "";
	private String audioTime = "";//发送音频文件的长度

	//发送or接收消息的类型
	public final static String CVTT_MSG_VOICE = "MSG_AUDIO";//send audio file

	public String toXML() {
		StringBuilder sbToList = new StringBuilder("");
		if ((toList != null) && (toList.size() > 0)) 
		{
			for (int i = 0; i < toList.size(); i++) 
			{
				String toNode = String.format(toNodeXml, toList.get(i).getUID());
				sbToList.append(toNode);
			}
		}

		String cvttXML = String.format(cvttMsgXML, type, fromUID, sbToList.toString(), content, attachment, remark, status, audioTime);

		return cvttXML;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}


	public String getFromUid() {
		return fromUID;
	}

	public void setFromUid(String fromUID) {
		this.fromUID = fromUID;
	}

	public Vector<CVTTUserNode> getToList() {
		return toList;
	}

	public void setToList(Vector<CVTTUserNode> toList) {
		this.toList = toList;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAttachment() {
		return attachment;
	}

	public void setAttachment(String attachment) {
		this.attachment = attachment;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getAudioTime() {
		return audioTime;
	}

	public void setAudioTime(String audioTime) {
		this.audioTime = audioTime;
	}
}
